package com.adcc.ags.gms.core.vo;

import com.adcc.ags.gms.core.entity.BaseEntity;
import com.adcc.ags.gms.core.entity.Menu;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * 二级菜单视图实体
 */
public class SubMenuVO extends BaseVO{

    // ID
    private long id;

    // 名称
    private String name;

    // 中文名称
    private String textCN;

    // 英文名称
    private String textEN;

    // 链接地址
    private String url;

    // 备注
    private String remark;

    /**
     * 构造函数
     */
    public SubMenuVO() {
        super();
    }

    /**
     * 构造函数
     * @param entity
     */
    public SubMenuVO(BaseEntity entity) {
        super(entity);
        Menu menu = (Menu)entity;
        id = menu.getId();
        name = menu.getName();
        textCN = menu.getTextCN();
        textEN = menu.getTextEN();
        url = menu.getUrl();
        remark = menu.getRemark();
    }

    /**
     * 构造函数
     * @param json
     */
    public SubMenuVO(String json) {
        super(json);
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTextCN() {
        return textCN;
    }

    public void setTextCN(String textCN) {
        this.textCN = textCN;
    }

    public String getTextEN() {
        return textEN;
    }

    public void setTextEN(String textEN) {
        this.textEN = textEN;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    public BaseEntity toEntity() {
        Menu menu = new Menu();
        menu.setId(this.id);
        menu.setName(this.name);
        menu.setTextCN(this.textCN);
        menu.setTextEN(this.textEN);
        menu.setUrl(this.url);
        menu.setRemark(this.remark);
        return menu;
    }

    @Override
    public String toJson() throws JsonProcessingException {
        return new ObjectMapper().writeValueAsString(this);
    }
}
